package com.zkflzl.store.controller;

import com.zkflzl.store.common.BaseResponse;
import com.zkflzl.store.model.dto.shopstock.ShopStockAddGoodsRequest;
import com.zkflzl.store.model.dto.shopstock.ShopStockAddRequest;
import com.zkflzl.store.model.dto.shopstock.ShopStockListRequest;
import com.zkflzl.store.service.ShopStockService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("/shopstock")
@Api(tags = "店铺库存模块")
public class ShopStockController {

    @Resource
    private ShopStockService shopStockService;

    /**
     * 添加货物
     */
    @PostMapping("/addgoods")
    public BaseResponse addShopStockGoods(@RequestBody ShopStockAddGoodsRequest shopStockAddGoodsRequest, HttpServletRequest request) {
        return shopStockService.addShopStockGoods(shopStockAddGoodsRequest, request);
    }

    /**
     * 添加、扣减库存
     */
    @PostMapping("/addstock")
    public BaseResponse addShopStock(@RequestBody ShopStockAddRequest stockAddRequest, HttpServletRequest request) {
        return shopStockService.updateShopStock(stockAddRequest, request);
    }

    /**
     * 删除货物
     */
    @PostMapping("/del")
    public BaseResponse delshopStock(@RequestParam String storeId, HttpServletRequest request) {
        return shopStockService.delShopStock(storeId, request);
    }

    /**
     * 查询门店下的库存
     */
    @PostMapping("/sel")
    public BaseResponse selshopStock(@RequestBody ShopStockListRequest shopStockListRequest, HttpServletRequest request) {
        return shopStockService.selShopStock(shopStockListRequest, request);
    }
}



